﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class LeagueFixtures : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.LeagueFixtures_PageTitle;
            //if (!HttpContext.Current.User.Identity.IsAuthenticated)
            //    Response.Redirect("Default.aspx");
            
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            
            //if (ou.TeamId == "Null")
            //    Response.Redirect("~/GeneralMessage.aspx?MessageString=274ggdizz5!lk");

            string LeagueId = null;
            string Season = null;
            if (Request.QueryString["LeagueId"] != null)
            {
                LeagueId = Request.QueryString["LeagueId"];
            }
            else
            {
                Response.Redirect("countries.aspx");
            }
            if (Request.QueryString["Season"] != null)
            {
                Season = Request.QueryString["Season"];
            }
            else
            {
                Season = "0";
            }

            this.LeagueIdHiddenField.Value = LeagueId;
            this.SeasonHiddenField.Value = Season;

            this.LeagueLinkButton.NavigateUrl = "~/League.aspx?LeagueId=" + LeagueId;
            this.LeaguefixturesTitleHyperlink.NavigateUrl = "~/League.aspx?LeagueId=" + LeagueId;
            this.LeaguefixturesTitleHyperlink.Text = GND.ReadNivdalStringData("LeagueId", "Nivdal_GetLeagueName", LeagueId);
            if (!IsPostBack)
            {
                //this.SqlDataSource1.SelectParameters.Add("LeagueId", LeagueId);
                //this.SqlDataSource1.SelectParameters.Add("Season", Season);
                //this.SqlDataSource1.SelectParameters.Add("Language", Language);
                this.SqlDataSource2.SelectParameters.Add("LeagueId", LeagueId);
                this.SqlDataSource2.SelectParameters.Add("Language", ou.Language);
                LanguageHiddenField.Value = ou.Language;
            }

            //Response.Write(LeagueId);
            //Response.Write(Season);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            SeasonHiddenField.Value = this.SeasonDropDownList.SelectedValue;
            RoundsListDataSource.DataBind();
            //Response.Redirect("LeagueFixtures.aspx?LeagueId="+LeagueId+"&Season="+SeasonDropDownList.SelectedValue);
        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }
    }
}